﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.WindowsAzure.ServiceRuntime;

namespace BasicClasses
{
    public class OcorrenciaDataSource
    {
        private static OcorrenciaContext context = new OcorrenciaContext();
        private static string tableName = RoleEnvironment.GetConfigurationSettingValue("OcorrenciaTable");

        public static IEnumerable<Ocorrencia> SelectAll()
        {
            return context.Ocorrencias;
        }

        public static void Add(Ocorrencia ocorrencia, string partitionKey) //partitionKey == Pais
        {
            ocorrencia.PartitionKey = partitionKey;
            ocorrencia.RowKey = Guid.NewGuid().ToString();
            context.AddObject(tableName, ocorrencia);
            context.SaveChanges();
        }
    }
}
